<?php
namespace Hive;
/**
 * Widget Object. 
 * 
 * It data (title,uri...) that are needed to display a widget, and make the list available
 * and handle inside the DB
 *
 * @author Xavier VILAIN
 * @package Hive
 * @property int 	$widgetid			Unique Id
 * @property string $language			Default Language
 * @property string $title				Title
 * @property string $description		Description
 * @property string $uri		 		URI (location of the widget)
 * @property string $frame				Using a frame or not
 * @property string	$params				Custom Params (such has actions)
 * @property bool 	$fullscreen			Widget can be display in full screen
 * @property bool 	$active				Is an active widget ?
 * @property bool 	$standard			Is a standard widget (can be deleted)
 */
class Widget extends \Fox\Object\Customizing {
	
	/**
	 * Link to widget category
	 * @var string
	 */
	const LINK_CATEGORY = 'category';
	
	/**
	 * Translated Description
	 * @return string
	 */
	public function description() {
		return $this->i18nParse('description');
	}
	
	/**
	 * Build final URI
	 * @return string
	 */
	public function uri() {
		return $this->uri;
	}
	
	/**
	 * UI Params
	 * @return array
	 */
	public function params() {
		$params['fullscreen'] = $this->fullscreen;
		$params['height'] = $this->height;
		$params['inframe'] = $this->inframe;
		return $params;
	}
		
	/**
	 * Check if the widget should be display in a frame ?
	 * @return bool
	 */
	public function isInFrame() {
		if($this->inframe == true) {
			return true;
		}
		return false;
	}
}
\Fox\Dao::infos(Widget::className(),new \Fox\Object\Info('widgets', \Fox\Databases::DB_APP));
//\Fox\Dao::useZone(Widget::className(),new \Fox\Dao\DiskTimeCacheZone(\Fox\Dao\DiskTimeCacheZone::PERIOD_FOREVER,Widget::cacheDirectory()));
// Link to Workflow
\Fox\Object\Links::add(\Fox\Dao::link(Widget\I18n::className(),Widget\I18n::LINK_REFERENCE)
	->to(Widget::className(),Widget::LINK_I18N)
	->on('widgetid')
);